# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=drbd-utils
pkgver=9.28.0
pkgrel=2
pkgdesc="Network-based RAID 1"
url="https://www.drbd.org"
arch="all"
license="GPL-2.0-or-later"
depends="bash"
makedepends="
	asciidoctor
	bison
	docbook-xsl
	flex
	keyutils-dev
	libxslt
	linux-headers
	po4a
	"
options="!check"  # no tests provided
provides="drbd=$pkgver-r$pkgrel"
subpackages="
	$pkgname-bash-completion
	$pkgname-doc
	$pkgname-openrc
	$pkgname-pacemaker::noarch
	"
source="https://pkg.linbit.com/downloads/drbd/utils/drbd-utils-$pkgver.tar.gz
	drbdsetup-permissions.patch
	drbd.initd
	0001-user-v84-makefile-use-libdir-when-installing.patch
	"

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	./configure \
		--host=$CHOST \
		--build=$CBUILD \
		--disable-dependency-tracking \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--with-pacemaker \
		--with-drbdmon \
		--with-bashcompletion \
		--without-udev \
		--without-heartbeat \
		--without-rgmanager \
		--without-xen \
		--without-83support
	make
}

package() {
	make DESTDIR="$pkgdir" install
	rmdir "$pkgdir"/var/lock

	install -m755 -D "$srcdir/drbd.initd" "$pkgdir/etc/init.d/drbd"

	mkdir -p "$pkgdir"/usr/share/bash-completion
	mv "$pkgdir"/etc/bash_completion.d \
		"$pkgdir"/usr/share/bash-completion/completions
}

pacemaker() {
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/lib/ocf
}

sha512sums="
57114bef36b09bcd17ff273c7c63c16cb68dfdb9b5eec71bc95780fd639ac40bd0ea5f388ae3fbed46770fdc0e7ba9bf9c712e4a915691fb55dc9576237470f2  drbd-utils-9.28.0.tar.gz
39a64a59577a28f8dc5f968bcfd35ab04b010ec1b9390dcaedefa609b8999ec4aabf2cfaf2db7dfd8348d8d09aca5720839de51b3bfb093960b3c61f92ebe4f0  drbdsetup-permissions.patch
0e2ff2244ec3f18944ff42609e9ec12de33d1b472fb9bb71f0f68ab67edfa2d2019059f405d58b33a43fcec6bf883f2be9ea3e7362d76f348b952a497a12757e  drbd.initd
10c7e75ff75cb6843786af3522a3fac8911667de52dc8cc3f760d3a5bd780a30e46e298d6098a5f8d223a72251c0e98287d343e295fbd0bd9f6be507282a28f0  0001-user-v84-makefile-use-libdir-when-installing.patch
"
